<?php
session_start();
include('config.php');
if(!empty($_POST[submit])){

$perintah_query=mysql_query("SELECT * FROM tbluser WHERE IDUser= '$_POST[username]' AND Password= md5 ('$_POST[password]')");
	if ($hasil_cek=mysql_num_rows($perintah_query))
	{
	//SUKSESS
	$datauser=mysql_fetch_array($perintah_query);
	$_SESSION[user]=$_POST[username];
	$_SESSION[nama]=$datauser[NamaUser];
	$_SESSION[level]=$datauser[Level];
//	echo $_SESSION[level];
	
	header("Location: index.php"); 
	}	else
	{
	//GAGAL LOGIN
	header("Location: index.php?err=yes");
	}
	}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtmll/DTD/xhtmll-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>
<?php echo nama_perusahaan; ?></title>
<link rel=icon href=image/images.ico type=image/x-icon>
<link rel=shortcut icon href=image/images.ico type=image/x-icon>
<link rel="stylesheet" type="text/css" href="css/style.css" />

      
</head>
<body><br />

<table width=85% class=table_dua align="center">
<tr><td colspan="2" align=center>
<h1 id="top">SISTEM INFORMASI PERSEDIAAN LAPTOP & GADGET<br></h1>

<marquee style="font-size:14pt;color:black; border-color:purple; border-style:solid;border-radius:5px;" bgcolor="white">
Selamat Datang <font color=blue><i><?php echo $_SESSION[nama]; ?></i></font> Di Applikasi Persediaan Laptop dan Gadget </marquee>
</td></tr>

<tr height="2"><td colspan="2" bgcolor="Black"></td></tr>
<tr valign="top"><td class="td_menu" rowspan="2">
<?php
if (empty($_SESSION[user])) { ?>
<h3 class="judul" align=center>Silahkan Login!</h3>
<p>Untuk bisa mengakses aplikasi ini, Silahkan anda login dengan menggunakan username dan password yang anda miliki, jika belum memiliki
password silahkan hubungi administrator !</p><img src="./image/login.png" align="center"></p>
<table width="100%" height="100" >
<form method="post" action="index.php">
<tr><td>Username</td><td><input type="text" name="username" size="15"></td></tr>
<tr><td>Password</td><td><input type="password" name="password" size="15"></td></tr>
<tr><td><input type="submit" name="submit" value="LOGIN"></td></tr>
</form>
</table>
<?php
} else {
include('menu.php');
}
if(!empty($_GET[err])){
?>
<p><img src="./image/alert.png" width=30 height=30 align=middle><font color="red"><b><blink>Gagal Login..!!</blink><br/>Cek Username Dan Passwordnya!</b></font></p>
<?php } ?>
</tr>
<tr valign="top"><td class="td_konten">
<?php
if(!empty($_GET[file]))
{
	if(file_exists("file/$_GET[file].php"))
	{
	include("file/$_GET[file].php");
	} else 
	{
	echo "<h2>Error !<br/>Halaman Tidak Di Temukan !</h2>";
	}
} else 
{ include('file/intro.php');}
?>
</td></tr>
<tr><td colspan="2" align="center"><h5 class="footer">  <?php echo $_SESSION[user]; ?><br/>PWL-04 &copy;2014</h5>
</td></tr>
</table>

</body>
</html>